﻿
namespace WebShopData
{
    public class OrderRow
    {
        public int ArticleID { get; set; }
        public int Quantity { get; set; }

        public OrderRow(int articleid, int quantity)
        {
            this.ArticleID = articleid;
            this.Quantity = quantity;
        }

        public override string ToString()
        {
            return string.Format("{0} {1}", ArticleID, Quantity);
        }

        public static bool operator ==(OrderRow firstArticle, OrderRow secondArticle)
        {
            if (object.ReferenceEquals(firstArticle, null) == true || object.ReferenceEquals(secondArticle, null))
                return false;
            return (firstArticle.ArticleID == secondArticle.ArticleID);
        }

        public static bool operator !=(OrderRow firstArticle, OrderRow secondArticle)
        {
            return !(firstArticle == secondArticle);
        }

        public override bool Equals(object obj)
        {
            return this == obj as OrderRow;
        }

        public override int GetHashCode()
        {
            return this.ArticleID | this.Quantity;
        }
    }
}
